#ifndef MANANDWOMAN_H
#define MANANDWOMAN_H
#include "person.h"
#include <QStringList>
#include <QString>
#include "Tools.h"
class Man: public Person
{
public:

    Man(QString name = "", int age = -1, QString location = "", int salary = -1);

    int getSalary(){return _salary;}

    friend ostream& operator <<(ostream &os, Man &p);
    friend istream& operator >>(istream &is, Man &p);

    virtual void outPut2Console();

private:
    int _salary;
};

class Range{
public:
    Range(int min, int max):_min(min),_max(max){}
    Range(QString str){
        QStringList strList = str.split(",");
        _min = strList.at(0).toInt();
        _max = strList.at(1).toInt();
    }

    bool inBetween(int x){ return _min <= x && x <= _max;}
    QString toString(){
        QString retStr = QString::number(_min);
        retStr.append(",");
        retStr.append(QString::number(_max));
        return retStr;
    }

    void FromString(QString str){
        QStringList sl = str.split(",");
        _min = sl.at(0).toInt();
        _max = sl.at(1).toInt();
    }
    QString getConditionStr(QString var){
        QString str = QString("%1>%2&&%1<%3").arg(var).arg(QString::number(_min)).arg(QString::number(_max));
        if(DEBUG){
            qDebug("%s\n", str.toStdString().data());
        }
        return str;
    }

private:
    int _min;
    int _max;
};

class Woman: public Person
{
public:
    Woman(QString name = "", int age =-1, QString location = "", Range* pExpectedSalary = new Range("0,0"),
          Range  * pExpectedAge = new Range("0,5"), QStringList expectedLocation = QString("").split(","));

    ~Woman(){
        SAFE_DELETE(_pExpectedSalary);
        SAFE_DELETE(_pExpectedAge);
    }

    friend ostream& operator <<(ostream &os, Woman &p);
    friend istream& operator >>(istream &is, Woman &p);

    virtual void outPut2Console();

    QString getConditionStr();

private:
    Range * _pExpectedSalary;
    Range  * _pExpectedAge;
    QStringList  _expectedLocation;
};



#endif // MANANDWOMAN_H
